﻿'use strict';

/* utils Service */
app.service('utils',
    ['$q', function ($q) {
        this.setTitle = function (title) {
            var body = document.getElementsByTagName('body')[0];
            document.title = title;
            var iframe = document.createElement("iframe");
            iframe.setAttribute("src", "img/favicon.ico?t=" + String(new Date().getTime()));
            var handler = function () {
                setTimeout(function () {
                    iframe.removeEventListener('load', handler);
                    document.body.removeChild(iframe);
                }, 0);
            };
            iframe.addEventListener('load', handler);
            document.body.appendChild(iframe);
        };
        
        this.wechatSiteName = window.location.pathname.substring(0, window.location.pathname.indexOf('/', 1));
    }]);